//
//  BNDOfficeDocSignedSwitch.m
//  OfficeDoc
//
//  Created by pie on 2022/4/5.
//  Copyright © 2022 pie. All rights reserved.
//

#import "BNDOfficeDocSignedSwitch.h"

@interface BNDOfficeDocSignedSwitch ()
@property (strong, nonatomic) UIButton *leftBtn;
@property (strong, nonatomic) UIButton *rightBtn;
@end

@implementation BNDOfficeDocSignedSwitch

- (instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        self.layer.cornerRadius = 25;
        self.layer.masksToBounds = YES;
        self.backgroundColor = UIColorWithHex(0xEDEEF1);
        
        _leftBtn = [UIButton buttonWithType:UIButtonTypeCustom];
        _leftBtn.backgroundColor = UIColor.whiteColor;
        _leftBtn.layer.cornerRadius = 17;
        _leftBtn.layer.masksToBounds = YES;
        [_leftBtn lk_setImage:BNDImageNamed(@"bnd_signed_switch_left")];
        [self addSubview:_leftBtn];
        [_leftBtn mas_makeConstraints:^(MASConstraintMaker *make) {
            make.size.mas_equalTo(CGSizeMake(76, 34));
            make.left.mas_equalTo(self.mas_left).offset(3);
            make.centerY.mas_equalTo(self);
        }];
        
        _rightBtn = [UIButton buttonWithType:UIButtonTypeCustom];
        _rightBtn.layer.cornerRadius = 17;
        _rightBtn.layer.masksToBounds = YES;
        [_rightBtn lk_setImage:BNDImageNamed(@"bnd_signed_switch_right")];
        [self addSubview:_rightBtn];
        [_rightBtn mas_makeConstraints:^(MASConstraintMaker *make) {
            make.size.mas_equalTo(CGSizeMake(76, 34));
            make.right.mas_equalTo(self.mas_right).offset(-3);
            make.centerY.mas_equalTo(self);
        }];
        
        @weakify(self)
        [[self.leftBtn rac_signalForControlEvents:UIControlEventTouchUpInside] subscribeNext:^(__kindof UIControl * _Nullable x) {
           @strongify(self)
            self.leftBtn.backgroundColor = UIColor.whiteColor;
            self.rightBtn.backgroundColor = UIColor.clearColor;
            BND_BLOCK_EXEC(self.blcok,[@(BNDLineWidthNone) stringValue]);
        }];
        
        [[self.rightBtn rac_signalForControlEvents:UIControlEventTouchUpInside] subscribeNext:^(__kindof UIControl * _Nullable x) {
            @strongify(self)
            self.leftBtn.backgroundColor = UIColor.clearColor;
            self.rightBtn.backgroundColor = UIColor.whiteColor;
            BND_BLOCK_EXEC(self.blcok,[@(BNDLineWidthCoarse) stringValue]);
        }];
    }
    
    return self;
}




@end
